$.namespace("restrpc.dashboard");
restrpc.dashboard = function () {  
	return  {
		initialize : function() {
			this.addHeader();
			this.addFooter();
		},
		
		addHeader : function() {
			var html = 
		    '<div class="navbar navbar-inverse navbar-fixed-top"> '+
		    '  <div class="navbar-inner"> '+
		    '    <div class="container"> '+
		    '      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> '+
		    '      <span class="icon-bar"></span> '+
		    '      <span class="icon-bar"></span> '+
		    '      <span class="icon-bar"></span> '+
		    '      </a> '+
		    '      <span class="brand">RestRpc Dashboard</span> '+
		    '      <div class="nav-collapse collapse"> '+
		    '        <ul class="nav"> '+
		    '          <li > <a href="../client/index.html">Client</a> </li> '+
		    '          <li > <a href="../server/index.html">Server</a> </li> '+
		    '          <li > <a href="../registry/index.html">Registry</a> </li> '+
		    '        </ul> '+
		    '      </div> '+
		    '    </div> '+
		    '  </div> '+
		    '</div> ';
			$(document.body).prepend(html);
			var index = -1;
			if (window.location.href.indexOf("/client") > 0) {
				index = 0;
			}
			else if (window.location.href.indexOf("/server") > 0) {
				index = 1;
			}
			else if (window.location.href.indexOf("/registry") > 0) {
				index = 2;
			}
			$(".navbar .nav li").eq(index).addClass("active");
		},
		
		addFooter : function() {
			var html = 
			'<footer class="footer">' + 
		    '  <div class="container">' +
		    '    <p>Code licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0</a>.</p> ' + 
		    '  </div> '+ 
		    ' </footer>';
		    
			$(document.body).append(html);
		},
		
		windowLocationSearch : function() {
			var params = window.location.search.substring(1).split("&");
			var paramObj = {};
			for ( var i = 0; i<params.length ; i++) {
				var param = params[i];
				paramObj[param.substring(0, param.indexOf("="))] = param.substring(param
						.indexOf("=") + 1);
			}
			return paramObj;
		}
	}
}();

$(document).ready(function() {
	restrpc.dashboard.initialize();
});
